<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="Clases.*" %>
<%if (session.getAttribute("UsuarioActual")!=null){ %>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Perfil</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<link href="dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="css/view.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="js/view.js"></script>

</head>
<body id="main_body" >
	<%if(Integer.parseInt(session.getAttribute("Tipo").toString())==1){ %>
<%@include file="menusecretarias.jsp" %>
<%}else{%>
<%@include file="menuprofesionales.jsp" %>
<%} %>
	<div class="container">
	<div class="starter-template">
	<img id="top" src="images/top.png" alt="" />
	<div id="form_container" />
	
		<h1><a>Perfil</a></h1>
		<form name="datosUsuario" class="appnitro"  method="post" accept-charset="ISO-8859-1">
			<div class="form_description">
				<h2>Datos de <%out.print(session.getAttribute("UsuarioActual")); %></h2>
				<p></p>
			</div>						
			
			<ul >
			
					<li id="li_1" >
		<label class="description" for="element_1">Nombre
 </label>
		<span>
			<input id="element_1_1" name= "element_1_1" class="element text" maxlength="255" size="20" value="<%
			out.print(session.getAttribute("Nombre")); %>"/>
			<label>Nombre</label>
		</span>
		<span>
			<input id="element_1_2" name= "element_1_2" class="element text" maxlength="255" size="30" value="<%
			out.print(session.getAttribute("Apellido")); %>"/>
			<label>Apellido</label>
		</span> 
		</li>		<li id="li_2" >
		<label class="description" for="element_2">Mail </label>
		<div>
			<input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" size="20" value="<%
			out.print(session.getAttribute("Mail")); %>"/> 
		</div> 
		</li>		<li id="li_3" >
		<label class="description" for="element_3">Contraseña </label>
		<div>
			<input id="element_3" name="element_3" class="element text medium" type="password" maxlength="255" value="<%=session.getAttribute("Contraseña").toString() %>"/> 
		</div> 
		</li>		<li id="li_4" >
		<label class="description" for="element_4">Repetir contraseña </label>
		<div>
			<input id="element_4" name="element_4" class="element text medium" type="password" maxlength="255" value="<%=session.getAttribute("Contraseña").toString() %>"/> 
		</div> 
		</li>
			
					<li class="buttons">
			    <input type="hidden" name="form_id" value="826830" />
			    
				<input id="guardar" class="button_text" type="submit" name="guardar" value="GUARDAR" onclick="save()"/>
				<input id="reset" class="button_text" type="submit" name="reset" value="CANCELAR" onclick="volver()"/>
		</li>
			</ul>
		</form>	
		</div>
	<img id="bottom" src="images/bottom.png" alt="" />
	</div>
	</div>
	<script type="text/javascript">
	function limpiar()
	{
		var elements = document.getElementsByTagName("input");
		for (var i=0; i < elements.length; i++) {
		  if (elements[i].type == "text") {
		    elements[i].value = "";
		  }
		}
	}
	function volver()
	{
		document.datosUsuario.action = "index.jsp";
		document.datosUsuario.submit();
	}
	function save()
	{
		var msj ="";
		if(document.getElementById("element_1_1").value=="")
			{msj+= "- Debe ingresar un nombre\n";}
		if(document.getElementById("element_1_2").value=="")
		{msj+= "- Debe ingresar un apellido\n";}
		if(document.getElementById("element_2").value=="")
		{msj+= "- Debe ingresar un mail\n";}
		else{
		 	var expr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		    if ( !expr.test(document.getElementById("element_2").value) ){msj+="El mail ingresado no es correcto\n";}
		}
		if(document.getElementById("element_3").value!=document.getElementById("element_4").value)
		{msj+="- Las contraseñas no coinciden\n";}
		if(msj!="")
			{alert(msj);}
		else{
			switch(parseInt(<%out.print(session.getAttribute("Tipo"));%>))
			{	
				case 0: 
						
						document.datosUsuario.action = "Final_IUDProfesional?TipoAccion=1";
						document.datosUsuario.submit();
						break;
				case 1: 
						document.datosUsuario.action = "Final_IUDSecretaria?TipoAccion=1";
						document.datosUsuario.submit();
						break;
			}		}
	}
	</script>
	
	
	<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>
	
   </body>
</html><%} else response.sendRedirect("LoginProfesional.jsp"); %>